using Commons.Models.Settings.Dtos.TradeValues;
using Commons.Models.Settings.Mappers.Locks;
using Commons.Models.TradeValues;

namespace Commons.Models.Settings.Mappers.TradeValues
{
	public class ProbabilityTradeValueMapper : IMapper<TradeValueDto, ITradeValue>
	{
		public ITradeValue Map (TradeValueDto config)
		{
			ProbabilityTradeValueDto dto = (ProbabilityTradeValueDto)config;

			ProbabilityTradeValue tradeValue = new ProbabilityTradeValue();

			foreach (ProbabilityEventDto eventDto in dto.Events)
			{
				ITradeValue probTradeValue = new TradeValuesMapper().Map(eventDto);
				tradeValue.AddValue(eventDto.ProbabilityValue, probTradeValue);
			}

			tradeValue.Lock = new LockMapper().Map(dto.Lock);

			return tradeValue;
		}
	}
}

